package com.zjgsu.coursecalendar.service.impl;

import com.zjgsu.coursecalendar.model.Homework;
import com.zjgsu.coursecalendar.model.HomeworkUser;
import com.zjgsu.coursecalendar.repository.HomeworkRepository;
import com.zjgsu.coursecalendar.repository.HomeworkUserRespository;
import com.zjgsu.coursecalendar.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class TeacherServiceImpl implements TeacherService {

    @Autowired
    private HomeworkRepository homeworkRepository;
    @Autowired
    private HomeworkUserRespository homeworkUserRespository;
    //作业的情况
    @Override
    public Homework getHomework(int courseId, int weekId) {

        Homework homework = new Homework();
        homework = homeworkRepository.findHomeworkByCourseIdAndWeekId(courseId,weekId);
        return homework;
    }

    //得到上交作业的用户的列表
    @Override
    public List<HomeworkUser> getHomeworkUser(int homeworkId) {
        return homeworkUserRespository.findHomeworkUsersByHomeworkId(homeworkId);
    }

    //上交的学生数量
    @Override
    public Integer getHomewworkUsernumber(List<HomeworkUser> homeworkUserList) {
        int number = homeworkUserList.size();
        return number;
    }
}
